//string 对象创建
#include <iostream>
#include <string>

using namespace std;

int main()
{
    //无参构造，创建一个空字符
    string s1;
    cout<<"s1:";
    cout<<s1<<endl;

    //初始化列表
    string s2({'h','e','l','l','o'});
    cout<<"s2:";
    cout<<s2<<endl;

    //中文字符
    string s3("今天是星期四");
    cout<<"s3:";
    cout<<s3<<endl;

    //提取前6个字符
    string s4("明天是星期五",6);
    cout<<"s4.size():"<<s4.size()<<endl;
    cout<<"s4:";
    cout<<s4<<endl;

    //提取前5个字符
    string s4_1("明天是星期五",5);
    cout<<"s4_1.size():"<<s4_1.size()<<endl;
    cout<<s4_1[4]<<endl;
    cout<<(int)s4_1.size()<<endl;//输出长度的整数值
    cout<<"s4_1:";
    cout<<s4_1<<endl;

    //拷贝构造函数
    string s5(s4);
    cout<<"s5:";
    cout<<s5<<endl;

    //创建包含8个字符'a'的字符串
    string s6(8,'o');
    cout<<"s6:";
    cout<<s6<<endl;

    return 0;
}